<?php
include 'config.php';

$p1 = ""; 
$p2 = "";
$refStr = "";

$formdata = $_POST['formData'];
$last = end(array_keys($formdata));
$next = next($formdata);
$prev = prev($formdata);

echo count($formdata);

// foreach($formdata as $key => $value) {
	// if ($last != $key && $next != $value) {
		// $p1 .= trim($value) . " ";
	// }
	// else
		// $p2 .= trim($value) . " ";
// }

foreach($formdata as $key => $value) {
$refStr .= trim($value). " ";
	}


$reflection = trim($refStr);
echo $reflection;


$lextimedate = $_SESSION['lextimedate'];
$userid = $_SESSION['userid'];
$query = "UPDATE lex SET lexreflect = '$reflection' WHERE lextimedate = '$lextimedate' AND userid = '$userid'";
$result = mysqli_query($con,$query) or die ("Could not record reflection in database");
//header('LOCATION: force-johndoe2.php'); //go to the next step of the form
?>
